home *** CD-ROM | disk | FTP | other *** search
- /*
- File: Events.h
-
- Contains: Event Manager Interfaces.
-
- Version: Technology: System 8
- Release: Universal Interfaces 3.0d3 on Copland DR1
-
- Copyright: © 1984-1996 by Apple Computer, Inc. All rights reserved.
-
- Bugs?: If you find a problem with this file, send the file and version
- information (from above) and the problem description to:
-
- Internet: apple.bugs@applelink.apple.com
- AppleLink: APPLE.BUGS
-
- */
- #ifndef __EVENTS__
- #define __EVENTS__
-
- #ifndef __OSUTILS__
- #include <OSUtils.h>
- #endif
- #ifndef __QUICKDRAW__
- #include <Quickdraw.h>
- #endif
- #ifndef __TYPES__
- #include <Types.h>
- #endif
-
- #ifdef __cplusplus
- extern "C" {
- #endif
-
- #if PRAGMA_IMPORT_SUPPORTED
- #pragma import on
- #endif
-
- #if PRAGMA_ALIGN_SUPPORTED
- #pragma options align=mac68k
- #endif
-
- typedef UInt16 EventKind;
- typedef UInt16 EventMask;
-
- enum {
- nullEvent = 0,
- mouseDown = 1,
- mouseUp = 2,
- keyDown = 3,
- keyUp = 4,
- autoKey = 5,
- updateEvt = 6,
- diskEvt = 7,
- activateEvt = 8,
- osEvt = 15,
- kHighLevelEvent = 23,
- mDownMask = 1 << mouseDown, /* mouse button pressed*/
- mUpMask = 1 << mouseUp, /* mouse button released*/
- keyDownMask = 1 << keyDown, /* key pressed*/
- keyUpMask = 1 << keyUp, /* key released*/
- autoKeyMask = 1 << autoKey, /* key repeatedly held down*/
- updateMask = 1 << updateEvt, /* window needs updating*/
- diskMask = 1 << diskEvt, /* disk inserted*/
- activMask = 1 << activateEvt, /* activate/deactivate window*/
- highLevelEventMask = 0x0400, /* high-level events (includes AppleEvents)*/
- osMask = 1 << osEvt, /* operating system events (suspend, resume)*/
- everyEvent = 0xFFFF /* all of the above*/
- };
-
-
- enum {
- charCodeMask = 0x000000FF,
- keyCodeMask = 0x0000FF00,
- adbAddrMask = 0x00FF0000,
- osEvtMessageMask = 0xFF000000, /* OS event messages. Event (sub)code is in the high byte of the message field.*/
- mouseMovedMessage = 0x00FA,
- suspendResumeMessage = 0x0001,
- resumeFlag = 1, /* Bit 0 of message indicates resume vs suspend*/
- convertClipboardFlag = 2 /* Bit 1 in resume message indicates clipboard change*/
- };
-
- typedef UInt16 EventModifiers;
-
- enum {
- /* modifiers */
- activeFlagBit = 0, /* activate? (activateEvt and mouseDown)*/
- btnStateBit = 7, /* state of button?*/
- cmdKeyBit = 8, /* command key down?*/
- shiftKeyBit = 9, /* shift key down?*/
- alphaLockBit = 10, /* alpha lock down?*/
- optionKeyBit = 11, /* option key down?*/
- controlKeyBit = 12, /* control key down?*/
- rightShiftKeyBit = 13, /* right shift key down?*/
- rightOptionKeyBit = 14, /* right Option key down?*/
- rightControlKeyBit = 15, /* right Control key down?*/
- activeFlag = 1 << activeFlagBit,
- btnState = 1 << btnStateBit,
- cmdKey = 1 << cmdKeyBit,
- shiftKey = 1 << shiftKeyBit,
- alphaLock = 1 << alphaLockBit,
- optionKey = 1 << optionKeyBit,
- controlKey = 1 << controlKeyBit,
- rightShiftKey = 1 << rightShiftKeyBit,
- rightOptionKey = 1 << rightOptionKeyBit,
- rightControlKey = 1 << rightControlKeyBit
- };
-
-
- enum {
- kNullCharCode = 0,
- kHomeCharCode = 1,
- kEnterCharCode = 3,
- kEndCharCode = 4,
- kHelpCharCode = 5,
- kBellCharCode = 7,
- kBackspaceCharCode = 8,
- kTabCharCode = 9,
- kLineFeedCharCode = 10,
- kVerticalTabCharCode = 11,
- kPageUpCharCode = 11,
- kFormFeedCharCode = 12,
- kPageDownCharCode = 12,
- kReturnCharCode = 13,
- kFunctionKeyCharCode = 16,
- kEscapeCharCode = 27,
- kClearCharCode = 27,
- kLeftArrowCharCode = 28,
- kRightArrowCharCode = 29,
- kUpArrowCharCode = 30,
- kDownArrowCharCode = 31,
- kDeleteCharCode = 127,
- kNonBreakingSpaceCharCode = 202
- };
-
- struct EventRecord {
- EventKind what;
- UInt32 message;
- UInt32 when;
- Point where;
- EventModifiers modifiers;
- };
- typedef struct EventRecord EventRecord;
-
- typedef UInt32 KeyMap[4];
- #if FOR_SYSTEM7_AND_SYSTEM8_COOPERATIVE
- typedef pascal void (*FKEYProcPtr)(void );
-
- #if GENERATINGCFM
- typedef UniversalProcPtr FKEYUPP;
- #else
- typedef FKEYProcPtr FKEYUPP;
- #endif
-
- enum {
- uppFKEYProcInfo = kPascalStackBased
- };
-
- #if GENERATINGCFM
- #define NewFKEYProc(userRoutine) \
- (FKEYUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppFKEYProcInfo, GetCurrentArchitecture())
- #else
- #define NewFKEYProc(userRoutine) \
- ((FKEYUPP) (userRoutine))
- #endif
-
- #if GENERATINGCFM
- #define CallFKEYProc(userRoutine) \
- CallUniversalProc((UniversalProcPtr)(userRoutine), uppFKEYProcInfo)
- #else
- #define CallFKEYProc(userRoutine) \
- (*(userRoutine))()
- #endif
- extern pascal void GetMouse(Point *mouseLoc)
- ONEWORDINLINE(0xA972);
-
- extern pascal Boolean Button(void )
- ONEWORDINLINE(0xA974);
-
- extern pascal Boolean StillDown(void )
- ONEWORDINLINE(0xA973);
-
- extern pascal Boolean WaitMouseUp(void )
- ONEWORDINLINE(0xA977);
-
- extern pascal UInt32 TickCount(void )
- ONEWORDINLINE(0xA975);
-
- extern pascal void GetKeys(KeyMap theKeys)
- ONEWORDINLINE(0xA976);
-
- extern pascal UInt32 KeyTranslate(const void *transData, UInt16 keycode, UInt32 *state)
- ONEWORDINLINE(0xA9C3);
-
- extern pascal UInt32 GetCaretTime(void)
- TWOWORDINLINE(0x2EB8, 0x02F4);
-
- #endif
- #if FOR_SYSTEM7_AND_SYSTEM8_DEPRECATED
- /* Obsolete event types & masks */
-
- enum {
- networkEvt = 10,
- driverEvt = 11,
- app1Evt = 12,
- app2Evt = 13,
- app3Evt = 14,
- app4Evt = 15,
- networkMask = 0x0400,
- driverMask = 0x0800,
- app1Mask = 0x1000,
- app2Mask = 0x2000,
- app3Mask = 0x4000,
- app4Mask = 0x8000
- };
-
- struct EvQEl {
- QElemPtr qLink;
- SInt16 qType;
- EventKind evtQWhat; /* this part is identical to the EventRecord as defined above */
- UInt32 evtQMessage;
- UInt32 evtQWhen;
- Point evtQWhere;
- EventModifiers evtQModifiers;
- };
- typedef struct EvQEl EvQEl;
-
- typedef EvQEl *EvQElPtr;
- /*
- This ProcPtr uses register based parameters on the 68k and cannot
- be written in or called from a high-level language without the help of
- mixed mode or assembly glue.
-
- typedef pascal void (*GetNextEventFilterProcPtr)(EventRecord *theEvent, Boolean *result);
-
- */
-
- #if GENERATINGCFM
- typedef UniversalProcPtr GetNextEventFilterUPP;
- #else
- typedef Register68kProcPtr GetNextEventFilterUPP;
- #endif
-
- enum {
- uppGetNextEventFilterProcInfo = SPECIAL_CASE_PROCINFO(11)
- };
-
- #if GENERATINGCFM
- #define NewGetNextEventFilterProc(userRoutine) \
- (GetNextEventFilterUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppGetNextEventFilterProcInfo, GetCurrentArchitecture())
- #else
- #define NewGetNextEventFilterProc(userRoutine) \
- ((GetNextEventFilterUPP) (userRoutine))
- #endif
-
- #if GENERATINGCFM
- #define CallGetNextEventFilterProc(userRoutine, theEvent, result) \
- CallUniversalProc((UniversalProcPtr)(userRoutine), uppGetNextEventFilterProcInfo, (theEvent), (result))
- #else
- /* (*GetNextEventFilterUPP) cannot be called from a high-level language without the Mixed Mode Manager */
- #endif
- typedef GetNextEventFilterUPP GNEFilterUPP;
- extern pascal QHdrPtr GetEvQHdr(void )
- THREEWORDINLINE(0x2EBC, 0x0000, 0x014A);
-
- extern pascal UInt32 GetDblTime(void)
- TWOWORDINLINE(0x2EB8, 0x02F0);
-
- extern pascal void SetEventMask(EventMask value)
- TWOWORDINLINE(0x31DF, 0x0144);
-
-
- #if GENERATING68K && !GENERATINGCFM
- #pragma parameter __D0 PPostEvent(__A0, __D0, __A1)
- #endif
- extern pascal OSErr PPostEvent(EventKind eventCode, UInt32 eventMsg, EvQElPtr *qEl)
- TWOWORDINLINE(0xA12F, 0x2288);
-
- #define KeyTrans(transData, keycode, state) KeyTranslate(transData, keycode, state)
- extern pascal Boolean GetNextEvent(EventMask eventMask, EventRecord *theEvent)
- ONEWORDINLINE(0xA970);
-
- extern pascal Boolean WaitNextEvent(EventMask eventMask, EventRecord *theEvent, UInt32 sleep, RgnHandle mouseRgn)
- ONEWORDINLINE(0xA860);
-
- extern pascal Boolean EventAvail(EventMask eventMask, EventRecord *theEvent)
- ONEWORDINLINE(0xA971);
-
-
- #if GENERATING68K && !GENERATINGCFM
- #pragma parameter __D0 PostEvent(__A0, __D0)
- #endif
- extern pascal OSErr PostEvent(EventKind eventNum, UInt32 eventMsg)
- ONEWORDINLINE(0xA02F);
-
-
- #if GENERATING68K && !GENERATINGCFM
- #pragma parameter __D0 OSEventAvail(__D0, __A0)
- #endif
- extern pascal Boolean OSEventAvail(EventMask mask, EventRecord *theEvent)
- TWOWORDINLINE(0xA030, 0x5240);
-
-
- #if GENERATING68K && !GENERATINGCFM
- #pragma parameter __D0 GetOSEvent(__D0, __A0)
- #endif
- extern pascal Boolean GetOSEvent(EventMask mask, EventRecord *theEvent)
- TWOWORDINLINE(0xA031, 0x5240);
-
- extern pascal void FlushEvents(EventMask whichMask, EventMask stopMask)
- TWOWORDINLINE(0x201F, 0xA032);
-
- extern pascal void SystemClick(const EventRecord *theEvent, WindowRef theWindow)
- ONEWORDINLINE(0xA9B3);
-
- extern pascal void SystemTask(void )
- ONEWORDINLINE(0xA9B4);
-
- extern pascal Boolean SystemEvent(const EventRecord *theEvent)
- ONEWORDINLINE(0xA9B2);
-
- #endif
-
- #if PRAGMA_ALIGN_SUPPORTED
- #pragma options align=reset
- #endif
-
- #if PRAGMA_IMPORT_SUPPORTED
- #pragma import off
- #endif
-
- #ifdef __cplusplus
- }
- #endif
-
- #endif /* __EVENTS__ */
-
-